<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    class Person {
        constructor(name, age) {
            this.name = name
            this.age = age
        }

        study() {
            //study方法放在了哪里?—类的原型对象上，供实例使用
            //通过Person实例调用study时，study中的this就是Person实例
            console.log(this)
        }
    }

    const p1 = new Person('tom', 18)
    p1.study()
    const x = p1.study
    x()


    //为了证明js自动在类中的方法上加了严格模式，this不指向window
    function demo() {
        console.log(this)
    }

    demo()

    function demo1() {
        'use strict'
        console.log(this)
    }

    demo1()


</script>
</body>
</html>